/**
 * 实现一个方法，要做到如下的特点
 *    "/dashboard/monitor"    => ['/dashboard', '/dashboard/monitor']
 *    "/a/b/c/d"              => ['/a', '/a/b', '/a/b/c', '/a/b/c/d']
 */
export const usePaths = (path: string) => {
  const tmp = path.split("/").slice(1); // ['dashboard', 'monitor']
  return tmp.reduce((prev: string[], item: string, index: number) => {
    if (index === 0) {
      prev.push(`/${item}`);
    } else {
      prev.push(`${prev[index - 1]}/${item}`);
    }

    return prev;
  }, []);
};
